package com.hf.buildtb.serviceImpl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Service;

import com.hf.base.shh.BaseServiceImpl;
import com.hf.buildtb.dao.BiCooperatorDao;
import com.hf.buildtb.entity.BiCooperator;
import com.hf.buildtb.formodel.BiCooperatorForm;
import com.hf.buildtb.service.BiCooperationService;

import sys.util.ChineseCharToEn;

@Service("biCooperationService")
public class BiCooperationServiceImpl extends BaseServiceImpl<BiCooperatorForm,BiCooperator,BiCooperatorDao> implements BiCooperationService  {

	@Override
	public BiCooperatorForm getPage(BiCooperator entity) {
		// TODO Auto-generated method stub
		BiCooperatorForm bForm = new BiCooperatorForm();
		String hql =" from BiCooperator ";
		Map<String, Object> params = new HashMap<String, Object>();
		if (!(entity==null) ){
			hql =hql+" where 1=1  ";
			if ((entity.getName()!=null)&&!entity.getName().equals("")) {
				params.put("name", entity.getName()+"%");
				hql =hql+" and name like:name ";
			}			 
			bForm.setEntity(entity);								 
		}		
		List<BiCooperator> list=	dao.find(hql,params);
		bForm.setEntities(list);
		bForm.setEntity(entity);
		return bForm;
	}

	@Override
	public boolean saveEntity(BiCooperator entiy) {
		// TODO Auto-generated method stub		
		entiy.setPy(ChineseCharToEn.getAllFirstLetter(entiy.getName()));
		dao.saveOrUpdate(entiy);
		return true;
	}
	
}
